package com.wy2.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wy2.entity.RoleModule;
import com.wy2.mapper.RoleModuleMapper;


import com.wy2.service.RoleModuleService;
import org.springframework.transaction.annotation.Transactional;

@Service
public class RoleModuleServiceImpl implements RoleModuleService {

	@Autowired
	private RoleModuleMapper rmr;
	
	@Override
	@Transactional
	/**
	 * 让角色模块中间表中添加数据
	 */
	public boolean save(String mid, String ids) {
		try {
			RoleModule ro = new RoleModule();

			String [] idss = ids.split(",");

			for(String idd : idss){

				ro.setMid(Integer.valueOf(idd));
				ro.setRid(mid);
				rmr.addsave(ro);
			}
			return true;
		} catch (Exception e) {

			throw new RuntimeException();
		}
	}

}
